﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="pddialog.aspx.cs" Inherits="newproduct_productdialog_pddialog" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../css/dialog.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="../js/product.js" type="text/javascript"></script>

</head>
<body>
    <form id="form1" runat="server">
    <div class="dg_k font14" width="600">
            <ul>
              <li class="dg_k_1 white"><strong><%=m_productname %>购买</strong><a href="#"  onclick="close_W()" class="dg_close img"></a></li>
              <li class="dg_k_4"></li>
              <li class="dg_k_3">价　　格<span class="dg_jg">￥<%=m_nowprice %></span> <span class="dg_k_f dg_jg2">￥<%=m_price %></span> </li>
              <%--<li class="dg_line"></li>--%>
              <%=lines1 %>
              <li class="dg_k_3" id="usertype"  runat="server">用户类型
                <input name="radiobutton" type="radio" value="0"  checked="checked" id="newuser"/>
                新用户
                <input name="radiobutton" type="radio" value="1" id="olduser" runat="server"/>
                老用户</li>
            <%--  <li class="dg_line"></li>--%>
            <%=lines2 %>
			  <li class="dg_k_3" id="usercheck"  runat="server">身份确认
		      手机号：<input id="txt_mobile" type="text" value="手机号/em号/rxt号" size="18" />
			    <br />
			    　　　　
			    密　码:
			    <input id="txt_pwd" type="text" size="18" />
			  </li>
              <li class="dg_line"></li>
          <%--    <li class="dg_k_3">使用期限
                <input name="radiobutton" type="radio" value="1" checked="checked" />
                一年
                <input type="radio" name="radiobutton" value="2" />
                二年
                <input type="radio" name="radiobutton" value="3" />
                三年 </li>--%>
                  <li class="dg_k_3">使用期限
                <input name="radiobutton" type="radio" value="1" checked="checked" />
                一年
                 </li>
              <li class="dg_line"></li>
              <li class="dg_k_3">数　　量
                <input name="txt_count" type="text" value="1" />
                件 </li>
              <li class="dg_k_4"></li>
              <li class="dg_k_2">
                <input type="button" name="Submit242" class="an3 img" value="立刻购买" onclick="GoBuy()" style="vertical-align:middle;text-align:center" />
                <input type="submit" name="Submit2222" class="an4 img" value="加入购物车" style="display:none" />
              </li>
            </ul>
        </div>
    <input id="productid" type="hidden"   value='<%=m_productid %>'/>
    </form>
    <script type="text/javascript">
        function IsMobile(mobile) {

            var regular = /^(13[0-9]|15[0-9]|18[0-9])\d{8}$/;
            if (mobile == "") {
                alert("手机号码不能为空，请输入！");
                $("#txt_mobile").focus();
                return false;
            }
            mobile = jQuery.trim(mobile);
            if (!regular.test(mobile)) {
                alert("请输入有效的手机号码！");
                $("#txt_mobile").focus();
                return false;
            }
        }
        function IsPassword(password) 
        {   
            if (password == "") 
            {
                alert("密码不能为空！");
                return false;
            }
        }
        function IsCount(count) 
        {
            if (count == "") 
            {
                alert("商品数量不能为空！");
                return false;
            }
            count = jQuery.trim(count);
            if (isNaN(count)) {
                alert("数量输入非法！");
                return false;
            }
            else 
            {
                if (count < 1) 
                {
                    alert("数量不能小于1！");
                    return false;
                 }
            }

        }

        $("#olduser").click(function () {

            //alert("old");
            var usertype = $("#olduser").val();
            //document.getElementById("usercheck").style.display = "block";
            //window.location = "pddialog.aspx?usertype='" + usertype + "'&ProductID='34'";
            window.parent.open_OldUser('34');
            //window.parent.hide();
            window.parent.close_singleW();
        })


        function close_W() {
            window.parent.close_W();
        }

        function GoBuy() {
            var productid = $("#productid").val();
            // IsMobile();
            if (productid == "") {
                alert();
                return false;
            }
            if(productid=="34") //一年版老用户
            {
                var mobile = $("#txt_mobile").val();
                var pwd = $("#txt_pwd").val();
                var count=$("#")
                IsMobile(mobile);
                IsPassword(pwd);
                IsCount(txt_count);
                //4.监测用户
                $.post("../handler/CheckUser.ashx", { username: mobile, pwd: pwd }, function (data) {
                    if (isNaN(data) == false && data > 0) {
                        Add_Cart(34);
                        close_W(); //关闭
                        return false;
                    }
                    else {

                        if (data == -1) {
                            alert("用户名或密码错误！");
                            return false;
                        }
                        else {

                            alert("对不起，您之前不是益盟的付费用户，不能享受老用户优惠.");
                            close_W(); //关闭
                            return false;

                        }

                    }

                })

            }

            Add_Cart(productid);
            close_W();
            return false;

           // alert(productid);
        }

    </script>

    <script  type="text/javascript">
        function Add_Cart(id) {
            if (id == '9' || id == '10') {
                var CartType = $F("txt_CartType");
                if (CartType == "") {
                    $F("Card_id", id);
                    Div_Display();
                    $("txt_UserName").focus();
                }
                else {
                    if (id == CartType) {
                        intoCart(id);
                    }
                    else {
                        var msg = CartType == '9' ? "您需要购买360元的充值卡" : "您需要购买720元的充值卡";
                        alert(msg);
                        return;
                    }
                }
            }
            else {
                intoCart(id);
            }
        }

        function intoCart(id) {
            var uid = "";
            if (id == '9' || id == '10') {
                uid = document.getElementById("txt_UserName").value;
            }

            // var _url = "http://pay.emoney.cn/shopping11.aspx";
            var _url = "http://pay.emoney.cn/shopping11.aspx";
            _url += "?ProductID=" + id + "&UserID=" + uid;
            //document.location = _url;
            alert(_url);
            window.open(_url);
        }
</script>

</body>
</html>
